function t(t, e) {
    if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
}

function e(t, e) {
    if (!t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    return !e || "object" != (void 0 === e ? "undefined" : a(e)) && "function" != typeof e ? t : e;
}

function n(t, e) {
    if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function, not " + (void 0 === e ? "undefined" : a(e)));
    t.prototype = Object.create(e && e.prototype, {
        constructor: {
            value: t,
            enumerable: !1,
            writable: !0,
            configurable: !0
        }
    }), e && (Object.setPrototypeOf ? Object.setPrototypeOf(t, e) : t.__proto__ = e);
}

var a = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
    return typeof t;
} : function(t) {
    return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
}, o = function() {
    function t(t, e) {
        for (var n = 0; n < e.length; n++) {
            var a = e[n];
            a.enumerable = a.enumerable || !1, a.configurable = !0, "value" in a && (a.writable = !0), 
            Object.defineProperty(t, a.key, a);
        }
    }
    return function(e, n, a) {
        return n && t(e.prototype, n), a && t(e, a), e;
    };
}(), i = function t(e, n, a) {
    null === e && (e = Function.prototype);
    var o = Object.getOwnPropertyDescriptor(e, n);
    if (void 0 === o) {
        var i = Object.getPrototypeOf(e);
        return null === i ? void 0 : t(i, n, a);
    }
    if ("value" in o) return o.value;
    var s = o.get;
    return void 0 !== s ? s.call(a) : void 0;
}, s = function(t) {
    return t && t.__esModule ? t : {
        default: t
    };
};

Object.defineProperty(exports, "__esModule", {
    value: !0
});

var r = s(require("../../app/application")), c = s(require("../../utils/log_util")), d = function(t) {
    if (t && t.__esModule) return t;
    var e = {};
    if (null != t) for (var n in t) Object.hasOwnProperty.call(t, n) && (e[n] = t[n]);
    return e.default = t, e;
}(require("../../app/constants")), u = s(require("../../app/use_case/task_data")), l = s(require("../../app/use_case/task_executor")), f = s(require("../../cloud/storage")), _ = s(require("../../utils/controller/page_controller")), p = s(require("../../app/infoc/wechatgamers_farm_sign")), g = s(require("../../utils/ad_percent")), h = s(require("../../utils/ad_type")), y = s(require("../../utils/sysinfo")), m = s(require("../../app/store")), S = s(require("../../app/use_case/interstitial_ad")), v = new (function(a) {
    function s() {
        t(this, s);
        var n = e(this, (s.__proto__ || Object.getPrototypeOf(s)).apply(this, arguments));
        return n._dlgSignSuccess = null, n._dlgSignSuccessReward = null, n._pinProgram = null, 
        n;
    }
    return n(s, _.default), o(s, [ {
        key: "onLoad",
        value: function(t, e) {
            var n = this;
            i(s.prototype.__proto__ || Object.getPrototypeOf(s.prototype), "onLoad", this).call(this, t, e), 
            r.default.notifyCenter.register(d.NotifyEvent.ATTENDANCE_INFO, this._onAttendanceInfoChanged.bind(this), null), 
            r.default.notifyCenter.register(d.NotifyEvent.TASK_DATA_CHANGE, this._onTaskDataChange.bind(this), null), 
            r.default.notifyCenter.register(d.NotifyEvent.CATCH_AWARD_SIGN, this._onCatchAwardSign.bind(this), null), 
            u.default.fetchAllTasks(), this._dlgSignSuccess = this._component.selectComponent("#dlgSignSuccess"), 
            this._dlgSignSuccessReward = this._component.selectComponent("#dlg_feed_reward_sign"), 
            this._pinProgram = this._component.selectComponent("#pin_program"), this._component.interstitialAd = new S.default(), 
            this._component.interstitialAd.successBack = function() {
                n._component.interstitialAd && n._component.interstitialAd.isSuccess && n._component.interstitialAd.show();
            };
        }
    }, {
        key: "onReady",
        value: function() {
            var t = this, e = g.default.getAdPercentInType("sign_percent");
            m.default.data.sign.signAdType = h.default.getType(e.type), r.default.attendanceLogic.finish({
                ebanstat: m.default.data.sign.signAdType
            }).then(function(n) {
                console.log("签到成功：", n), t._component.store.data.sign.signAward = n.data.feed / 1e3, 
                t._component.store.data.sign.extreward = n.data.extreward, t._dlgSignSuccessReward.show(e), 
                t._featchAttendaceData();
            }).catch(function() {
                t._featchAttendaceData();
            }), this._component.setData({
                isShowSignTask: r.default.switch.data().sign_task
            }), console.log("readay");
        }
    }, {
        key: "onShow",
        value: function() {
            console.log("show"), this._dlgSignSuccessReward && this._component.store.data.sign.dlgSignSuccessRewardShow && (console.log("this._dlgSignSuccessReward.show();"), 
            this._component.store.data.sign.dlgSignSuccessRewardDouble || (this._component.store.data.sign.dlgSignSuccessRewardDouble = !0, 
            r.default.extreLogic.verb3(this._component.store.data.sign.extreward, m.default.data.sign.signAdType)), 
            this._dlgSignSuccessReward.show(null, !0)), this.signVideoAdInit();
        }
    }, {
        key: "signVideoAdInit",
        value: function() {
            r.default.videoAd.init(), r.default.videoAd.adLoadStatusBack = function(t) {
                m.default.data.sign.isHasVideo = t;
            };
        }
    }, {
        key: "_featchAttendaceData",
        value: function() {
            var t = this;
            r.default.attendanceLogic.info().then(function(e) {
                t._component.store.data.signDays = e.day, t._component.store.data.isAttendanced = e.attendanced, 
                t._component.setData({
                    signPageDays: e.day
                }), console.log("获取到的签到数据:", e, t._component.store.data.signDays), f.default.get([ d.default.ATTENDANCE_REMIND_SWITCH ]).then(function(n) {
                    console.log("签到提醒开关状态拉取!", n);
                    var a = "1" == n.data.value_data.attendance_remind_switch;
                    t._component.store.data.signRemind = a, t._component.setData({
                        pageSignRemind: a
                    }), !r.default.attendanceLogic.hasReportSingInMine && p.default.report(p.default.SCENE_MINE, e.day, "1" == n.data.value_data.attendance_remind_switch ? 1 : 2, p.default.CLICK_SHOW), 
                    r.default.attendanceLogic.hasReportSingInMine = !0;
                }).catch(function() {});
            }).catch(function() {});
        }
    }, {
        key: "onUnload",
        value: function() {
            i(s.prototype.__proto__ || Object.getPrototypeOf(s.prototype), "onUnload", this).call(this), 
            r.default.notifyCenter.remove(d.NotifyEvent.ATTENDANCE_INFO, this._onAttendanceInfoChanged.bind(this), null), 
            r.default.notifyCenter.remove(d.NotifyEvent.TASK_DATA_CHANGE, this._onTaskDataChange.bind(this), null), 
            r.default.notifyCenter.remove(d.NotifyEvent.CATCH_AWARD_SIGN, this._onCatchAwardSign.bind(this), null);
        }
    }, {
        key: "productAllEgg",
        value: function() {
            var t = this;
            this._component.store.data.index.chickenTipsShow = !1, setTimeout(function() {
                t._component.store.data.index.chickenTipsShow = !0;
            }, 10);
        }
    }, {
        key: "taskClickCallback",
        value: function(t) {
            c.default.d(c.default.TAG_ALL, "点击签到任务列表：!", t);
            var e = t.detail, n = e.task_type;
            "add_to_my_mini_program" !== n ? l.default.isSuppoert(n) ? (e.res_config.task_id = e.task_id, 
            e.res_config.tap = 4, e.res_config.click = 100, e.res_config.reportId = e.task_id, 
            e.res_config.from = e.from ? e.from : "", l.default.do(n, e.res_config)) : c.default.e(c.default.TAG_ALL, "[onClickTaskItem] task not support task_type", n) : this._pinProgram.show();
        }
    }, {
        key: "_updateTaskStatus",
        value: function(t) {
            (t = t.filter(function(t) {
                if (!t.res_config.platform || t.res_config.platform == r.default.sysInfo.platform() || t.res_config.platform == y.default.PLATFORM_ANDROID_IOS) return !0;
            })).sort(function(t, e) {
                return t.task_stat == e.task_stat ? t.task_order - e.task_order : t.task_stat - e.task_stat;
            }), this._component.store.data.sign.taskList = t;
        }
    }, {
        key: "_onTaskDataChange",
        value: function() {
            c.default.i(c.default.TAG_ALL, "签到页获取到的任务数据：", u.default.getAllTasks());
            var t = u.default.getTaskByTaskType("task_sign");
            t && this._updateTaskStatus(t.sub_tasks);
        }
    }, {
        key: "_onAttendanceInfoChanged",
        value: function() {
            for (var t = arguments.length, e = Array(t), n = 0; n < t; n++) e[n] = arguments[n];
            var a = e[1][0];
            this._component.store.data.signDataList = a.signDateList, this._component.store.data.signDays = a.day;
        }
    }, {
        key: "onClickSignRemind",
        value: function(t) {
            var e = this;
            console.log("点击签到收到的参数：", t), this._component.data.pageSignRemind ? r.default.attendanceLogic.closeRemind(t.detail.formId).then(function() {
                e._changeRemindStatus(!1);
            }).catch(function() {}) : r.default.attendanceLogic.openRemind(t.detail.formId).then(function() {
                e._changeRemindStatus(!0);
            }).catch(function() {});
        }
    }, {
        key: "_changeRemindStatus",
        value: function(t) {
            var e = this;
            f.default.set({
                attendance_remind_switch: t ? "1" : "0"
            }).then(function() {
                e._component.store.data.signRemind = t, e._component.setData({
                    pageSignRemind: t
                });
            }).catch(function() {});
        }
    }, {
        key: "_onCatchAwardSign",
        value: function() {
            var t = this;
            r.default.extreLogic.verb3(this._component.store.data.sign.extreward, m.default.data.sign.signAdType).then(function(e) {
                t._component.store.data.sign.dlgSignSuccessRewardDouble = !0, t._dlgSignSuccessReward.show(null, !0);
            }).catch(function(t) {
                wx.showToast({
                    title: t.msg,
                    icon: "none"
                });
            });
        }
    } ]), s;
}())();

exports.default = v;